Make 'Ok' work for the file chooser entry
authorFederico Mena Quintero <federico@novell.com>
Wed, 26 Mar 2008 20:22:50 +0000 (20:22 +0000)
committerFederico Mena Quintero <federico@src.gnome.org>
Wed, 26 Mar 2008 20:22:50 +0000 (20:22 +0000)
2008-03-26  Federico Mena Quintero  <federico@novell.com>

* gtk/gtkfilechooserentry.c (commit_completion_and_refresh): New
helper function; factored out from the functions that commit the
current suggested autocompletion and that refresh the entry's paths.
(gtk_file_chooser_entry_activate): Use commit_completion_and_refresh().
(_gtk_file_chooser_entry_get_file_part): Likewise.
(_gtk_file_chooser_entry_get_current_folder): Likewise.  This
makes the entry have the correct paths when *not* using any form
of completion (and makes the file chooser work when clicking the
OK button).

Signed-off-by: Federico Mena Quintero <federico@gnu.org>
svn path=/trunk/; revision=19937

ChangeLog
gtk/gtkfilechooserentry.c

index 2e70115e12a44634f52a591ee2fc34b07699db9d..bb6dabd02a7e1bd64b709fb73380ea8c3d30a782 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-03-26  Federico Mena Quintero  <federico@novell.com>
+
+       * gtk/gtkfilechooserentry.c (commit_completion_and_refresh): New
+       helper function; factored out from the functions that commit the
+       current suggested autocompletion and that refresh the entry's paths.
+       (gtk_file_chooser_entry_activate): Use commit_completion_and_refresh().
+       (_gtk_file_chooser_entry_get_file_part): Likewise.
+       (_gtk_file_chooser_entry_get_current_folder): Likewise.  This
+       makes the entry have the correct paths when *not* using any form
+       of completion (and makes the file chooser work when clicking the
+       OK button).
+
 2008-03-25  Richard Hult  <richard@imendio.com>
 
        * gdk/quartz/gdkevents-quartz.c:
index afcb5bf20ab95a5862778488bf28644c5a263be4..217de4f621f95b058e027911e5a571de39eb1fc7 100644 (file)
@@ -1165,10 +1165,8 @@ gtk_file_chooser_entry_focus_out_event (GtkWidget     *widget,
 }
 
 static void
-gtk_file_chooser_entry_activate (GtkEntry *entry)
+commit_completion_and_refresh (GtkFileChooserEntry *chooser_entry)
 {
-  GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (entry);
-
   if (chooser_entry->has_completion)
     {
       gtk_editable_set_position (GTK_EDITABLE (entry),
@@ -1176,7 +1174,14 @@ gtk_file_chooser_entry_activate (GtkEntry *entry)
     }
 
   refresh_current_folder_and_file_part (chooser_entry, REFRESH_WHOLE_TEXT);
+}
+
+static void
+gtk_file_chooser_entry_activate (GtkEntry *entry)
+{
+  GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (entry);
 
+  commit_completion_and_refresh (chooser_entry);
   GTK_ENTRY_CLASS (_gtk_file_chooser_entry_parent_class)->activate (entry);
 }
 
@@ -1663,11 +1668,7 @@ _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
 const GtkFilePath *
 _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
 {
-  if (chooser_entry->has_completion)
-    {
-      gtk_editable_set_position (GTK_EDITABLE (chooser_entry),
-                                GTK_ENTRY (chooser_entry)->text_length);
-    }
+  commit_completion_and_refresh (chooser_entry);
   return chooser_entry->current_folder_path;
 }
 
@@ -1686,14 +1687,7 @@ _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
 const gchar *
 _gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry)
 {
-  if (chooser_entry->has_completion)
-    {
-      gtk_editable_set_position (GTK_EDITABLE (chooser_entry),
-                                GTK_ENTRY (chooser_entry)->text_length);
-    }
-
-  refresh_current_folder_and_file_part (chooser_entry, REFRESH_WHOLE_TEXT);
-
+  commit_completion_and_refresh (chooser_entry);
   return chooser_entry->file_part;
 }